# -*- coding:utf-8 -*-
# @Time:2024/4/1921:01
# @Author:miuzg
# @FileName:new test2.py
# @Software:PyCharm

import openpyxl

# 读取数据
wb = openpyxl.load_workbook('salaries.xlsx',data_only=True)
sheet = wb.active

title = []
for i in sheet[1]:
    title.append(i.value)
print(title)

# 员工信息
staff = []

# 从第二行开始取，取到最后一行
for row in sheet[2:sheet.max_row]:
    for data in row:
        staff.append(data.value)
    s_book = openpyxl.Workbook()
    s_sheet = s_book.active
    s_sheet.append(title)
    s_sheet.append(staff)
    s_book.save(f'{staff[0]} salary.xlsx')
    staff.clear() # 添加完数据后，就清空staff列表